package com.freshmarket.freshmarket.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
    public static String getDateTime(){
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
    }
    public static String getTime(){
        return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
    }
    public static String getDate(){
        return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    }
    public static String getFormatTime(long starttime){

        long DD = 86400000;
        long HH = 3600000;
        long MM = 60000;
        long d = 0;
        long h = 0;
        long m = 0;
        long s = 0;
        d = starttime/DD;
        h = starttime % DD / HH;
        m = starttime % DD % HH / MM;
        s = starttime % DD % HH % MM / 1000;
        StringBuilder stringBuilder=new StringBuilder();
        if (d != 0) {
            stringBuilder.append(d + "天");
        }
        if (h != 0) {
            stringBuilder.append(h + "小时");
        }
        if(m!=0){
            stringBuilder.append(m + "分钟");
        }
        if(s!=0){
            stringBuilder.append(s + "秒");
        }
        return  stringBuilder.toString();

    }
}
